<?php

namespace App\Models\Cashier;

use Illuminate\Database\Eloquent\Model;

class Brand extends Model
{
    protected $guarded = [];

    //每个品牌有很多商品
    public function products()
    {
        return $this->hasMany('App\Models\Cashier\Product');
    }


    /**
     * 检查品牌底下是否有商品
     * @param $id
     * @return bool
     */
    static function check_product($id)
    {
        $brand = self::with('products')->find($id);
        if ($brand->products->isEmpty()) {
            return true;
        }

        return false;
    }


}
